package com.letoken.platform.repo.app.manager;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.letoken.platform.repo.app.dao.AppUserTeamPathMapper;
import com.letoken.platform.repo.app.po.AppUserTeamPath;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author wyl
 * @date 2023/1/3 11:14
 * @Version 1.0
 */
@Log4j2
@Repository
public class AppUserTeamPathManager {

    @Autowired
    private AppUserTeamPathMapper appUserTeamPathMapper;


    /**
     *  修改被推荐人 所有团队用户path
     * @param pathIdList 所有下级id
     * @param invitePath path路径
     */
    public void updateTeamPathByInvite(List<Integer> pathIdList,String invitePath){
        LambdaUpdateWrapper<AppUserTeamPath> updateWrapper = Wrappers.lambdaUpdate();
        updateWrapper.in(AppUserTeamPath::getUserId,pathIdList)
                .setSql("invite_path = concat(invite_path, ',' ,'" + invitePath + "')" );
        appUserTeamPathMapper.update(null, updateWrapper);
    }
}
